<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
	<head>
		<base href="<%=basePath%>">
		<meta charset="utf-8" />
		<title>药品信息</title>
		<meta name="description" content="overview & stats" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<link href="static/css/bootstrap.min.css" rel="stylesheet" />
		<link href="static/css/bootstrap-responsive.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="static/css/font-awesome.min.css" />
		<!--提示框-->
		<script type="text/javascript" src="static/js/jquery.tips.js"></script>
	    <meta name="viewport" content="width=device-width, initial-scale=1.0">
	    <meta http-equiv="X-UA-Compatible" content="ie=edge">
	    <link rel="stylesheet" href="static/css/common.css">
	    <link rel="stylesheet" href="static/css/bootstrap.css">
	    <link rel="stylesheet" href="static/css/font-awesome-4.7.css">
	    <link rel="stylesheet" href="static/css/hzxx.css">
	    <script src="static/js/jquery-1.11.3.js"></script>
	    <script src="static/js/bootstrap.js"></script>
	    <script src="static/laydate/laydate.js"></script>
	</head>
<body>
		<div class="container-fluid" id="zhongxin">
        <div class="row">
            <div class="col-sm-12 col-md-12 col-lg-12 main">
                <form action="drug/add.do" name="form" id="form"  method="post">     
                <input name="id" id="id" type="hidden">          
                    <div class="r1">
                        <div class="col-sm-2 col-md-2 col-lg-2 lf left ">
                            <span>药品编号:</span>
                        </div>
                        <div class="col-sm-10 col-md-10 col-lg-10 lf right">
                            <input type="text" class="consignee" id="ypbh" name="ypbh" placeholder="请输入药品编号">
                        </div>
                    </div> 
                    <div class="r2">
                        <div class="col-sm-2 col-md-2 col-lg-2 lf left ">
                            <span>药品名称:</span>
                        </div>
                        <div class="col-sm-10 col-md-10 col-lg-10 lf right">
                            <input type="text" class="consignee" id="ypmc" name="ypmc" placeholder="请输入药品名称">
                        </div>
                    </div>                     
                   	<div class="r4">
                        <div class="col-sm-2 col-md-2 col-lg-2 lf left ">
                            <span>药品类型:</span>
                        </div>
                        <div class="col-sm-10 col-md-10 col-lg-10 lf right">                           
                            <select name="yplx" id="yplx"  data-placeholder="请选择药品类型" >
                                <option value="" class="active">===请选择===</option>
                                <c:forEach items="${listYplx}" var="datas">
									<option value="${datas.NAME}">${datas.NAME}</option>
								</c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="r5">
                        <div class="col-sm-2 col-md-2 col-lg-2 lf left ">
                            <span>计量单位:</span>
                        </div>
                        <div class="col-sm-10 col-md-10 col-lg-10 lf right">
                            <select name="dw" id="dw"  data-placeholder="请选择药品单位" >
                                <option value="" class="active">===请选择===</option>
                                <c:forEach items="${listYpdw}" var="datas">
									<option value="${datas.NAME}">${datas.NAME}</option>
								</c:forEach>
                            </select>
                        </div>
                    </div>
                    <div class="r6">
                        <div class="col-sm-2 col-md-2 col-lg-2 lf left ">
                            <span>药品单价:</span>
                        </div>
                        <div class="col-sm-10 col-md-10 col-lg-10 lf right">
                            <input type="text" onkeyup="value=value.replace(/[^\d.]/g,'')"  class="consignee" id="dj" name="dj" placeholder="请输入单价(默认为元)" style="width:30%;">
                        </div>
                    </div>
                    <div class="r7">
                        <div class="col-sm-2 col-md-2 col-lg-2 lf left ">
                            <span>药品用法:</span>
                        </div>
                        <div class="col-sm-10 col-md-10 col-lg-10 lf right">
                            <textarea name="ypyf" id="ypyf" cols="30" rows="12" placeholder="请输入药品用法" class="textarea"></textarea>
                        </div>
                    </div>
                    <div class="bottom col-sm-offset-5 col-sm-2 col-md-offset-5 col-md-2 col-lg-offset-5 col-lg-2">
                        <a class="btn btn-success" style="width:100%;" onclick="save();">提交</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <div id="zhongxin2" class="center" style="display:none"><br/><br/><br/><br/><img src="static/images/jiazai.gif" /><br/><h4 class="lighter block green"></h4></div>

	
		<!-- 引入 -->
		<script type="text/javascript">window.jQuery || document.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");</script>
		<script src="static/js/bootstrap.min.js"></script>
		<script src="static/js/ace-elements.min.js"></script>
		<script src="static/js/ace.min.js"></script>
		<script type="text/javascript" src="static/js/chosen.jquery.min.js"></script><!-- 下拉框 -->
		<script type="text/javascript" src="static/js/bootstrap-datepicker.min.js"></script><!-- 日期框 -->
		
		<script type="text/javascript">
		
		$(function() {
			
			//单选框
			$(".chzn-select").chosen(); 
			$(".chzn-select-deselect").chosen({allow_single_deselect:true}); 
			
			//日期框
			$('.date-picker').datepicker();
			
		});		
		
		</script>
<script type="text/javascript">
		
top.hangge();
//保存
function save(){		
	if($("#ypbh").val()==""){
		$("#ypbh").focus();
		return false;
	}
	if($("#ypmc").val()==""){
		$("#ypmc").focus();
		return false;
	}
	if($("#yplx").val()==""){
		$("#yplx").focus();
		return false;
	}
	if($("#dw").val()==""){
		$("#dw").focus();
		return false;
	}
	if($("#dj").val()==""){
		$("#dj").focus();
		return false;
	}
	if($("#ypyf").val()==""){
		$("#ypyf").focus();
		return false;
	}	
	
	$("#form").submit();
	$("#zhongxin").hide();
	$("#zhongxin2").show();
}


$("#ypbh").blur(function(){
	  var ypbh = $("#ypbh").val();
	  $.ajax({
			type: "POST",
			url: '<%=basePath%>drug/hasYp.do',
	    	data: {ypbh:ypbh},
			dataType:'json',
			cache: false,
			success: function(data){
				 if("success" == data.result){
					 alert("药品编号已存在，请重新输入！");
					 document.getElementById("ypbh").value="";
				 }
			}
		});
	  
});
		
</script>
	
</body>
</html>